text: Avoid clash of preedit and placeholder
authorMatthias Clasen <mclasen@redhat.com>
Fri, 22 May 2020 02:42:53 +0000 (22:42 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 22 May 2020 14:48:33 +0000 (10:48 -0400)
Take preedit into account when determining the
visibility of placeholder text.

gtk/gtktext.c

index d60e036208532fe785537a0a968b3cef2d603a3f..cb655e0d487a018c24a6d3ff713ad7b3a0215203 100644 (file)
@@ -3488,6 +3488,7 @@ update_placeholder_visibility (GtkText *self)
 
   if (priv->placeholder)
     gtk_widget_set_child_visible (priv->placeholder,
+                                  priv->preedit_length == 0 &&
                                   gtk_entry_buffer_get_length (priv->buffer) == 0);
 }
 
@@ -4150,7 +4151,7 @@ gtk_text_commit_cb (GtkIMContext *context,
     }
 }
 
-static void 
+static void
 gtk_text_preedit_changed_cb (GtkIMContext *context,
                              GtkText      *self)
 {
@@ -4171,8 +4172,9 @@ gtk_text_preedit_changed_cb (GtkIMContext *context,
       cursor_pos = CLAMP (cursor_pos, 0, g_utf8_strlen (preedit_string, -1));
       priv->preedit_cursor = cursor_pos;
       g_free (preedit_string);
-    
+
       gtk_text_recompute (self);
+      update_placeholder_visibility (self);
     }
 }